package Thread;

class Singletonlazy{
    private volatile static Singletonlazy instance = null;
    private static Object lock = new Object();
    private Singletonlazy(){}
    public static Singletonlazy getInstance(){
        if(instance==null){
            synchronized (lock) {
                if(instance==null){
                    instance=new Singletonlazy();
                }
            }
        }
        return instance;
    }
}
public class ThreadDemo08 {
    public static void main(String[] args) {
        Singletonlazy s1 = Singletonlazy.getInstance();
        Singletonlazy s2 = Singletonlazy.getInstance();
        System.out.println(s1==s2);
    }
}
